package com.gcxy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.gcxy.conf.result.R;
import com.gcxy.conf.result.ResultCodeEnum;
import com.gcxy.entity.DataDictionary;
import com.gcxy.mapper.DataDictionaryMapper;
import com.gcxy.service.DataDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hy
 * @since 2023-08-16
 */
@Service
public class DataDictionaryServiceImpl extends ServiceImpl<DataDictionaryMapper, DataDictionary> implements DataDictionaryService {

    @Autowired
    private DataDictionaryMapper dataDictionaryMapper;
    @Override
    public R queryDicList() {
        LambdaQueryWrapper<DataDictionary> lm = new LambdaQueryWrapper<>();
        lm.select(DataDictionary::getDataName,DataDictionary::getDataId);
        List<Map<String,Object>> list= dataDictionaryMapper.selectMaps(lm);
        if (ObjectUtils.isEmpty(list)) {
            return R.Failed(ResultCodeEnum.REQUEST_NOT_FOUND.getCode(),"查询为空");
        }

        return R.Success(list);
    }
}
